define(['underscore','backbone','jquery'], function(_,Backbone,$){
    var WidgetView = Backbone.View.extend({
        tagName : 'div',
        events : {
            'click .actions .save' : 'save',
            'click .actions .cancel' : 'cancel'
        },
        edit : function(event){
            $(this.el).addClass('editting');
            return false;
        },
        save : function(event){
            var exported = this.$('.export input:checkbox').attr('checked') ? 1 : 0;
            this.model.save({content:this.$('textarea').val(),exported : exported});
            return false;
        },
        cancel : function(event){
            this.render();
            $(this.el).removeClass('editting');
            return false;
        }
    });
    return WidgetView;
});